//
//  LDOAuthViewController.swift
//  LDMicroblog
//
//  Created by pro on 15/9/9.
//  Copyright (c) 2015年 pro. All rights reserved.
//

import UIKit

class LDOAuthViewController: UIViewController,UIWebViewDelegate {
    
    let WEB_client_id = "2211504851"//appkey
    let WEB_redirect_uri = "http://gzitcast.com"//回调地址
    
    //计算属性 此种写法只有getter方法 readonly
    var webView: UIWebView {
    
        return view as! UIWebView
    }
    

    //退出
    @IBAction func closeBtnClick(sender: AnyObject) {
        
        dismissViewControllerAnimated(true, completion: nil)
        
    }
    
    //MARK:-------------------------------------------
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        loadOAuthPage()
    }
    
    //MARK:加载授权页面
    private func loadOAuthPage() {
    
        let urlStr = "https://api.weibo.com/oauth2/authorize?client_id=" + WEB_client_id + "&" + "redirect_uri=" + WEB_redirect_uri
        let url = NSURL(string: urlStr)!
        webView.loadRequest(NSURLRequest(URL: url))

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
   //MARK: 代理
    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
        
        println("------\(request.URL)")
        
        return true
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
